package com.shunwang.caipiao.data.container;

import java.util.ArrayList;
import java.util.List;

import com.shunwang.caipiao.vo.NumberIntervalDetailVo;
import com.shunwang.caipiao.vo.NumberIntervalVo;

public class Top5NumberCallBack implements NumberIntervalContainerCallBack<List<NumberIntervalDetailVo>> {

	@Override
	public List<NumberIntervalDetailVo> doCallBack(NumberIntervalSeat seat) {
		List<NumberIntervalVo> seatNums = seat.getNumberIntervalVoList();
		List<NumberIntervalDetailVo> result = new ArrayList<NumberIntervalDetailVo>();
		
		for(NumberIntervalVo vo : seatNums){
			Integer num = vo.getSource();
			List<Integer> numbers = vo.getIntervalDetail();
			if(numbers == null || numbers.size() < 1){
				continue;
			}
			StatisticsNumberInterval interval = new StatisticsNumberInterval();
			int topNum = 3;
			if(numbers.size() < 3){
				topNum = numbers.size();
			}
			numbers = interval.statistice(numbers, topNum);
			if(numbers != null || numbers.size() > 1){
				result.add(new NumberIntervalDetailVo(num,numbers));
			}
		}
		return result;
	}

}